package com.example.demo1.insurance;

import java.util.Scanner;

public class BaoXian {
    public static void main(String[] args) {
        for (int i = 0; ; i++) {
            int sco = 0;
            int round;
            int money;
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入年龄");
            int age = sc.nextInt();
            while (age<0||age>99){
                System.out.println("输入有误，请输入0-99");
                age = sc.nextInt();
            }

            sc.nextLine();
            System.out.println("请输入性别“F(女)|M（男）");
            String sex = sc.nextLine();
            while (!sex.equals("F") && !sex.equals("M")) {
                System.out.println("输入有误，请重新输入");
                sex = sc.nextLine();
            }
            System.out.println("请输入是否已婚Y（已婚）|N（未婚）");
            String hun = sc.nextLine();
            while (!hun.equals("Y") && !hun.equals("N")) {
                System.out.println("输入有误，请重新输入");
                hun = sc.nextLine();
            }

            System.out.println("请输入抚养人数，有效值为0-9");
            int sum1 = sc.nextInt();
            while (sum1<0||sum1>9){
                System.out.println("输入有误，请输入0-9");
                sum1 = sc.nextInt();
            }
            System.out.println("请输入投保额（100000-5000000之间的整数）");
            int sum2 = sc.nextInt();
            while (sum2<10000||sum2>5000000){
                System.out.println("输入有误，请输入10000-5000000之间的整数");
                sum2 = sc.nextInt();
            }

            if(age<40&&age>=20){
                sco+=6;
            }else if (age>=40&&age<60){
                sco+=4;
            }else {
                sco+=2;
            }
            if (sex.equals("M")){
                sco+=5;
            }else {
                sco+=3;
            }
            if (hun.equals("Y")){
                sco+=3;
            }
            else {
                sco+=5;
            }
            round = Math.round(sum1);
            if(round>3){
                round = 3;
            }
            sco -= round;
            if (sco>=10){
                money= (int) (sum2*0.006);
            }else {
                money= (int) (sum2*0.001);
            }
            System.out.println("保险费为："+money);

            System.out.println("是否继续执行，请输入Y||N");
            String yn= sc.next();
            while (!yn.equals("Y") && !yn.equals("N")){
                System.out.println("输入有误，请重新输入Y或者N");
                yn= sc.next();
            }
            if (yn.equals("N")){
                break;
            }
        }

    }
}